<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Constructs EvStat watcher object</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="evstat.attr.html">EvStat::attr</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="evstat.createstopped.html">EvStat::createStopped</a></div>
 <div class="up"><a href="class.evstat.html">EvStat</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="evstat.construct" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">EvStat::__construct</h1>
  <p class="verinfo">(PECL ev &gt;= 0.2.0)</p><p class="refpurpose"><span class="refname">EvStat::__construct</span> &mdash; <span class="dc-title">Constructs EvStat watcher object</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-evstat.construct-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="methodname"><strong>EvStat::__construct</strong></span>
    ( <span class="methodparam">
    <span class="type">string</span>
     <code class="parameter">$path</code>
   </span>
   , <span class="methodparam">
    <span class="type">double</span>
     <code class="parameter">$interval</code>
   </span>
   , <span class="methodparam">
    <span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span>
     <code class="parameter">$callback</code>
   </span>
   [, <span class="methodparam">
    <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span>
     <code class="parameter">$data</code>
    <span class="initializer"> = <strong><code>NULL</code></strong></span>
   </span>
   [, <span class="methodparam">
    <span class="type">int</span>
     <code class="parameter">$priority</code>
    <span class="initializer"> = 0</span>
   </span>
  ]] )</div>

  <p class="para rdfs-comment">
   Constructs EvStat watcher object and starts the watcher automatically.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-evstat.construct-parameters">
  <h3 class="title">参数</h3>
  <dl>

   
    <dt>

     <em><code class="parameter">path</code></em>
    </dt>

    <dd>

     <p class="para">
      The path to wait for status changes on.
     </p>
    </dd>

   
   
    <dt>

     <em><code class="parameter">interval</code></em>
    </dt>

    <dd>

     <p class="para">
      Hint on how quickly a change is expected to be detected and should
      normally be specified as
      <strong><code>0.0</code></strong>
      to let
      <em class="emphasis">libev</em>
      choose a suitable value.
     </p>
    </dd>

   
   
    <dt>

     <em><code class="parameter">callback</code></em>
    </dt>

    <dd>

     <p class="para">
      See
      <a href="ev.watcher-callbacks.html" class="link">Watcher callbacks</a>
      .
     </p>
    </dd>

   
   
    <dt>

     <em><code class="parameter">data</code></em>
    </dt>

    <dd>

     <p class="para">
      Custom data associated with the watcher.
     </p>
    </dd>

   
   
    <dt>

     <em><code class="parameter">priority</code></em>
    </dt>

    <dd>

     <p class="para">
      <a href="class.ev.html#ev.constants.watcher-pri" class="link">Watcher priority</a>
     </p>
    </dd>

   
  </dl>

 </div>

 <div class="refsect1 returnvalues" id="refsect1-evstat.construct-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns EvStat watcher object on succes.
  </p>
 </div>

 <div class="refsect1 examples" id="refsect1-evstat.construct-examples">
  <h3 class="title">范例</h3>

 <div class="example" id="example-3539">
   <p><strong>Example #1 Monitor changes of /var/log/messages</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;Use&nbsp;10&nbsp;second&nbsp;update&nbsp;interval.<br /></span><span style="color: #0000BB">$w&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">EvStat</span><span style="color: #007700">(</span><span style="color: #DD0000">"/var/log/messages"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">8</span><span style="color: #007700">,&nbsp;function&nbsp;(</span><span style="color: #0000BB">$w</span><span style="color: #007700">)&nbsp;{<br />&nbsp;echo&nbsp;</span><span style="color: #DD0000">"/var/log/messages&nbsp;changed\n"</span><span style="color: #007700">;<br /><br />&nbsp;</span><span style="color: #0000BB">$attr&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$w</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">attr</span><span style="color: #007700">();<br /><br />&nbsp;if&nbsp;(</span><span style="color: #0000BB">$attr</span><span style="color: #007700">[</span><span style="color: #DD0000">'nlink'</span><span style="color: #007700">])&nbsp;{<br />&nbsp;&nbsp;</span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"Current&nbsp;size:&nbsp;%ld\n"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$attr</span><span style="color: #007700">[</span><span style="color: #DD0000">'size'</span><span style="color: #007700">]);<br />&nbsp;&nbsp;</span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"Current&nbsp;atime:&nbsp;%ld\n"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$attr</span><span style="color: #007700">[</span><span style="color: #DD0000">'atime'</span><span style="color: #007700">]);<br />&nbsp;&nbsp;</span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"Current&nbsp;mtime:&nbsp;%ld\n"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$attr</span><span style="color: #007700">[</span><span style="color: #DD0000">'mtime'</span><span style="color: #007700">]);<br />&nbsp;}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;</span><span style="color: #0000BB">fprintf</span><span style="color: #007700">(</span><span style="color: #0000BB">STDERR</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"`messages`&nbsp;file&nbsp;is&nbsp;not&nbsp;there!"</span><span style="color: #007700">);<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$w</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">stop</span><span style="color: #007700">();<br />&nbsp;}<br />});<br /><br /></span><span style="color: #0000BB">Ev</span><span style="color: #007700">::</span><span style="color: #0000BB">run</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="evstat.attr.html">EvStat::attr</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="evstat.createstopped.html">EvStat::createStopped</a></div>
 <div class="up"><a href="class.evstat.html">EvStat</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
